package com.summer.data.rs.datatype;

/**
 * @author 345480567@qq.com
 */

public class PageInfo {
    private static ThreadLocal<PageInfo> tl = new ThreadLocal<>();

    public static void set(PageInfo info) {
        tl.set(info);
    }

    public static PageInfo get() {
        PageInfo pageInfo = tl.get();
        return pageInfo;
    }

    public static void set(int pageNo, int pageSize) {
        set(new PageInfo(pageNo, pageSize));
    }

    public static void clear() {
        set(null);
    }

    private Integer pageNo;

    private Integer pageSize;

    public PageInfo(Integer pageNo, Integer pageSize) {
        this.pageNo = pageNo;
        this.pageSize = pageSize;
    }

    public Integer getPageNo() {
        return pageNo;
    }

    public Integer getOffset() {
        Integer offset = (pageNo -1)*pageSize;
        return offset;
    }

    public Integer getPageSize() {
        return pageSize;
    }

}

